<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head th:replace="~{segmentation/_right_bottom_header::_header_common(~{::title},~{::link},~{::style})}">
        <meta charset="utf-8">
    <title>定时任务日志编辑</title>
    <link>
    <style type="text/css"></style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>定时任务日志编辑</legend>
        </fieldset>
        <form class="layui-form" id="scheduledTasksLogFormEdit" action="">
            <input type="hidden" id="id" name="id" th:value="${p.id}"/>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="required-red">*</span>定时任务编号</label>
                <div class="layui-input-block">
                    <input type="text" name="scheduledTasksId" id="scheduledTasksId" lay-verify="required|number|scheduledTasksId"
                           lay-verType="tips"
                           th:value="${p.scheduledTasksId}"
                           placeholder="请输入定时任务编号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="required-red">*</span>任务名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" id="name" lay-verify="required|name"
                           lay-verType="tips"
                           th:value="${p.name}"
                           placeholder="请输入任务名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="required-red">*</span>任务编码</label>
                <div class="layui-input-block">
                    <input type="text" name="code" id="code" lay-verify="required|code"
                           lay-verType="tips"
                           th:value="${p.code}"
                           placeholder="请输入任务编码" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="required-red">*</span>任务参数</label>
                <div class="layui-input-block">
                    <input type="text" name="param" id="param" lay-verify="required|param"
                           lay-verType="tips"
                           th:value="${p.param}"
                           placeholder="请输入任务参数" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="required-red">*</span>执行第几次</label>
                <div class="layui-input-block">
                    <input type="text" name="executeIndex" id="executeIndex" lay-verify="required|number|executeIndex"
                           lay-verType="tips"
                           th:value="${p.executeIndex}"
                           placeholder="请输入执行第几次" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="required-red">*</span>执行状态</label>
                <div class="layui-input-block">
                    <input type="text" name="executeStatus" id="executeStatus" lay-verify="required|number|executeStatus"
                           lay-verType="tips"
                           th:value="${p.executeStatus}"
                           placeholder="请输入执行状态" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="required-red">*</span>开始时间</label>
                <div class="layui-input-block">
                    <input type="text" name="executeStartTime" id="executeStartTime" lay-verify="required|executeStartTime"
                           lay-verType="tips"
                           th:value="${#dates.format(p.executeStartTime, 'yyyy-MM-dd HH:mm:ss')}"
                           placeholder="请选择开始时间" readonly autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="required-red">*</span>结束时间</label>
                <div class="layui-input-block">
                    <input type="text" name="executeEndTime" id="executeEndTime" lay-verify="required|executeEndTime"
                           lay-verType="tips"
                           th:value="${#dates.format(p.executeEndTime, 'yyyy-MM-dd HH:mm:ss')}"
                           placeholder="请选择结束时间" readonly autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="required-red">*</span>执行时间</label>
                <div class="layui-input-block">
                    <input type="text" name="duration" id="duration" lay-verify="required|number|duration"
                           lay-verType="tips"
                           th:value="${p.duration}"
                           placeholder="请输入执行时间" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><span class="required-red">*</span>结果</label>
                <div class="layui-input-block">
                    <input type="text" name="result" id="result" lay-verify="required|result"
                           lay-verType="tips"
                           th:value="${p.result}"
                           placeholder="请输入结果" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item custom-text-align"
                 sec:authorize="hasPermission(#authorization.authentication,'button','SCHEDULED_TASKS_LOG_LIST_MANAGEMENT:edit')">
                <a class="layui-btn" lay-submit="" lay-filter="scheduledTasksLogFormEditSubmit">保存</a>
            </div>
        </form>
    </div>
</div>

<div th:replace="~{segmentation/_tail::_tail_common}"></div>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script th:inline="javascript">
    /*<![CDATA[*/
    [# sec:authorize="hasPermission(#authorization.authentication,'button','SCHEDULED_TASKS_LOG_LIST_MANAGEMENT:edit')"]
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer;




        //自定义验证规则
        form.verify({
            scheduledTasksId: function (value) {
                if (value.length > 19) {
                    return '定时任务编号最多19个字符';
                }
            },
            name: function (value) {
                if (value.length > 64) {
                    return '任务名称最多64个字符';
                }
            },
            code: function (value) {
                if (value.length > 64) {
                    return '任务编码最多64个字符';
                }
            },
            param: function (value) {
                if (value.length > 512) {
                    return '任务参数最多512个字符';
                }
            },
            executeIndex: function (value) {
                if (value.length > 10) {
                    return '执行第几次最多10个字符';
                }
            },
            executeStatus: function (value) {
                if (value.length > 10) {
                    return '执行状态最多10个字符';
                }
            },
            executeStartTime: function (value) {
            },
            executeEndTime: function (value) {
            },
            duration: function (value) {
                if (value.length > 10) {
                    return '执行时间最多10个字符';
                }
            },
            result: function (value) {
                if (value.length > 2000) {
                    return '结果最多2000个字符';
                }
            },
        });

        //监听提交
        form.on('submit(scheduledTasksLogFormEditSubmit)', function (data) {
            $.ajax({
                type: 'POST',
                url: '/module/job/scheduled/tasks/log/edit',
                data: data.field,
                dataType: 'json',
                success: function (data) {
                    if (data.code == Result.SUCCESS) {
                        layer.msg('成功!', {
                            icon: 1,
                            shade: [0.3, '#f5f5f5'],
                            time: 1500
                        }, function () {
                            $("#scheduledTasksLogList", window.parent.document).attr('value', 1);
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    } else {
                        layer.msg(data.msg, {
                            icon: 2,
                            time: 3000
                        });
                    }
                }, error: function (data) {
                    console.log(data);
                },
            });
            return false;//返回false防止重复提交
        });
    });
    [/]
    /*]]>*/
</script>

</body>
</html>